package com.itheima.web;

import com.github.pagehelper.PageInfo;
import com.itheima.domain.Syslog;
import com.itheima.service.SyslogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Component
@RequestMapping("/sysLog")
public class SyslogController {
    @Autowired
    private SyslogService syslogService;

    @RequestMapping("/findAll")
    public String findAll(Model model, @RequestParam(name = "page", required = true, defaultValue = "1") int page, @RequestParam(name = "pageSize", required = true, defaultValue = "4") int pageSize) {
        List<Syslog> syslogList = syslogService.findAll(page, pageSize);
        PageInfo pageInfo = new PageInfo(syslogList);
        model.addAttribute("sysLogs", pageInfo);
        return "syslog-list";
    }

}
